

public class StringDemo2 {
    public static boolean isJavaFielName(String filaName){
        //String[] split = filaName.split("\\.");
        //return split[split.length - 1].equals("java");
        int x = filaName.indexOf(".");
        String str = filaName.substring(x + 1);
        if (!str.equals("java")) {
            return false;
        } else {
            return true;
        }
    }

    public static boolean isCorrectEmailAddr(String emainAddress){
        int n = -1, m = -1;
        n = emainAddress.indexOf('@');
        m = emainAddress.indexOf('.');
        return n != -1 && m != -1 && n < m;
    }

    public static void countPos(String stra, String strb){
        System.out.println("第一次出现的位置：" + stra.indexOf(strb));
        System.out.println("最后一次出现的位置:" + stra.lastIndexOf(strb));
        System.out.println("出现次数：" + ((stra.split(strb)).length - 1));
    }

    public static void wordCount(String s){
        String[] strings=s.split(" ");
    }

    public static void main(String[] args) {

        String stra ,strb;

        stra="abc.doc";
        System.out.println("文件名" +stra + "是java源文件？"+isJavaFielName(stra));

        stra="abc.java";
        System.out.println("文件名" +stra + "是java源文件？"+isJavaFielName(stra));

        stra="abc.22.java";
        System.out.println("文件名" +stra + "是java源文件？"+isJavaFielName(stra));

        stra="abc@sina.com";
        System.out.println("邮箱地址："+ stra + "   "+ isCorrectEmailAddr(stra));

        stra="abcsina.com";
        System.out.println("邮箱地址："+stra + "   "+ isCorrectEmailAddr(stra));

        stra="abc12edeff12341212khi";
        strb="12";
        countPos(stra, strb);

        stra = "This is a book! It is mine! It is very interesting ";
        wordCount(stra);

    }

}

